console.log(456456456);
chrome.runtime.onInstalled.addListener(() => {
  console.log(34234234);
  DBdata("clear"); //清除插件保存的本地数据
});
//插件用的数据都存储在storage.local中
function DBdata(mode, callback, data) {
  //操作本地存储的函数
  if (mode == "set") {
    //保存本地数据
    console.log("set-LocalDB");
    chrome.storage.local.set({ LocalDB: data });
  } else if (mode == "get") {
    //获取
    chrome.storage.local.get("LocalDB", function (response) {
      typeof callback == "function" ? callback(response) : null;
    });
  } else if (mode == "clear") {
    //清空
    chrome.storage.local.clear();
  }
}
// 获取cookies
chrome.cookies.getAll({ url: "http://XXX/*", name: "test" }, (c) => {
  console.log(c);
});
// 代理浏览器请求
chrome.runtime.onMessage.addListener((action, _, cb) => {
  if (action.type === HTTP) {
    // action
  }
});
